package com.wine.game.wine.controller.group;


import com.wine.game.wine.config.NettyConfig;
import com.wine.game.wine.nettywebsocket.common.MessageEnum;
import com.wine.game.wine.nettywebsocket.entity.GroupMessageEntity;
import com.zenofung.common.utils.PageUtils;
import com.zenofung.common.utils.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.data.redis.core.ZSetOperations;
import org.springframework.web.bind.annotation.*;

import java.util.Map;
import java.util.Set;

@RestController
@RequestMapping("wine/group")
public class GroupController {
    @Autowired
    private RedisTemplate redisTemplate;

    /**
     * 列表
     */
    @PostMapping("/list")
    @CrossOrigin
    //@RequiresPermissions("wine:article:list")
    public R list(@RequestBody GroupMessageEntity groupMessageEntity){
        //发送群聊消息 已登录
        ZSetOperations<String, String> zSetOps = redisTemplate.opsForZSet();
        Set<String> range = zSetOps.range(NettyConfig.MESSAGE_GROUP_KEY + groupMessageEntity.getGroupId(), 0, 200);
        return R.ok().put("page", range);
    }

}
